﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Entity;

public partial class Admin_Pages_SizeEdit : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["login"] != null)
            {
                int sizeid = Convert.ToInt32(Request.Params["sizeid"]);
                SizeUI size = new SizeUI();
                DataSet ds = size.Get(sizeid);
                txtSize.Text = ds.Tables[0].Rows[0]["Size_Name"].ToString();
                txtPrice.Text = ds.Tables[0].Rows[0]["Price"].ToString();
            }
            else
            {
                Response.Redirect("../Login.aspx");
            }
            
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        int sizeid = Convert.ToInt32(Request.Params["sizeid"]);
        SizeUI size = new SizeUI();

        int result = size.Update(sizeid, txtSize.Text.Trim(), float.Parse(txtPrice.Text.Trim()));
        if (result > 0)
        {
            Response.Write("<script>alert('Update successful'); window.location='../Pages/SizeList.aspx';</script>");
        }
        else
        {
            Response.Write("<script>alert('Update fail'); window.location='../Pages/SizeList.aspx';</script>");
        }
    }
}
